package org.wmine.algo;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Stats extends JFrame
{int i;
	public Stats(String[]attribs,int colknt)
	{
		final Container c=this.getContentPane();
		this.setTitle("Statistical Analysis");
		
		JPanel mainPanel=new JPanel();
		mainPanel.setLayout(new GridLayout(3,1));

		JPanel pan1=new JPanel();
		pan1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Find Mean,Mode,Median "));
		pan1.setLayout(new GridLayout(2,3));
		final JCheckBox [] cb1=new JCheckBox[colknt];
		for(i=0;i<colknt;i++)
		{
				cb1[i]=new JCheckBox(attribs[i]);
				cb1[i].addActionListener(new ActionListener(){public void actionPerformed(ActionEvent ae)
				{
					System.out.println(ae.getActionCommand()+">>"+ae.paramString());
				    if(cb1[i].isSelected()){System.out.println("yes");}
				} 
				
		}); 
		pan1.add(cb1[i]);
		}
		JPanel pan2=new JPanel();
		pan2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Find Correlation Between "));
		pan2.setLayout(null);
		final JComboBox com1=new JComboBox();
		int j;
		for(j=0;j<colknt;j++)
		{
		com1.addItem(new String(attribs[j]));
		}
		com1.setEditable(false);
		com1.setBounds(10,45,110,20);
		final JComboBox com2=new JComboBox();
		for(j=0;j<colknt;j++)
		{
			com2.addItem(new String(attribs[j]));
		}
		com2.setEditable(false);
		com2.setBounds(140,45,110,20);
		pan2.add(com1);pan2.add(com2);
		JPanel pan3=new JPanel();
		pan3.setLayout(null);
		JButton but1=new JButton("Process");
		JButton but2=new JButton("Cancel");
		but1.setBounds(10,45,110,20);
		but2.setBounds(140,45,110,20);
		pan3.add(but1);
		pan3.add(but2);
		but1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent ae)
		{
			dispose();
			ProgressBar pb=new ProgressBar();
			pb.getDialog();
		}});
	
		mainPanel.add(pan1);
		mainPanel.add(pan2);
		mainPanel.add(pan3);
		c.add(mainPanel);
		
	}
}